package swagenda.ui;

import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import swagenda.data.Service;
import swagenda.ui.components.SWAButton;
import swagenda.ui.components.SWALabel;

@SuppressWarnings("serial")
public class PlaceWindowLarge extends JDialog
{
	Service place;

    private SWAButton closeButton;
    private JScrollPane jScrollPaneReview;
    private SWALabel lblAddress;
    private SWALabel lblLocPhone;
    private SWALabel lblName;
    private SWAButton okButton;
    private JTextArea review;
    private JTextField title;
    
    public PlaceWindowLarge(Frame parent, Service p)
    {
        super(parent);
        place = p;
        init();
        getRootPane().setDefaultButton(closeButton);
    }
    
    public void init()
    {
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        okButton = new SWAButton("ok");
        closeButton = new SWAButton("close");
        jScrollPaneReview = new JScrollPane();

    	lblName = new SWALabel(place.name);
        lblLocPhone = new SWALabel(place.locality.name + " " + place.phone, Font.PLAIN);
        lblAddress = new SWALabel(place.address, Font.PLAIN);
        title = new JTextField(place.title);
        review = new JTextArea();

        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                closeMe();
            }
        });
        okButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                save();
            }
        });

        title.setFont(new Font("Verdana", Font.PLAIN, 14));
        review.setColumns(20);
        review.setFont(new Font("Verdana", Font.PLAIN, 14));
        review.setRows(5);
        review.setText(place.review);
        review.setLineWrap(true);
        review.setWrapStyleWord(true);
        jScrollPaneReview.setViewportView(review);

        closeButton.setName("closeButton");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPaneReview, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(okButton, GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(title, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblName)
                        .addGap(18, 18, 18)
                        .addComponent(lblLocPhone))
                    .addComponent(lblAddress))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblName)
                    .addComponent(lblLocPhone))
                .addGap(7, 7, 7)
                .addComponent(lblAddress)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPaneReview, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(closeButton)
                    .addComponent(okButton))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }
    
    public void closeMe() { setVisible(false); }
    public void save() 
    {
    	
    }
}
